<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><!--Head--><head>
    <meta charset="utf-8">
    <title>ThinkPHP5 后台登录</title>
    <meta name="description" content="login page">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--Basic Styles-->
    <link href="__ADMIN__/style/bootstrap.css" rel="stylesheet">
    <link href="__ADMIN__/style/font-awesome.css" rel="stylesheet">
    <!--Beyond styles-->
    <link id="beyond-link" href="__ADMIN__/style/beyond.css" rel="stylesheet">
    <link href="__ADMIN__/style/demo.css" rel="stylesheet">
    <link href="__ADMIN__/style/animate.css" rel="stylesheet">
</head>
<!--Head Ends-->
<!--Body-->

<body>
    <div class="login-container animated fadeInDown">
        <form action="login" method="post">
            <div class="loginbox bg-white">
                <div class="loginbox-title">SIGN IN</div>
                <div class="loginbox-textbox">
                    <input  class="form-control" placeholder="用户名" name="username" type="text">
                </div>
                <div class="loginbox-textbox">
                    <input class="form-control" placeholder="密码" name="password" type="password">
                </div>
                <div class="loginbox-submit">
                    <input class="btn btn-primary btn-block" value="登录" type="button" id="submit">
                </div>
                <span  style="text-align: center;color:red;font-weight: bold; display: none;" id="msg">

                </span>

            </div>
                <div class="logobox">
                    <p class="text-center">ThinkPHP5 后台登录</p>
                </div>
        </form>
    </div>
    <!--Basic Scripts-->
    <script src="__ADMIN__/style/jquery.js"></script>
    <script src="__ADMIN__/style/bootstrap.js"></script>
    <script src="__ADMIN__/style/jquery_002.js"></script>
    <!--Beyond Scripts-->
    <script src="__ADMIN__/style/beyond.js"></script>
    <script>
        jQuery("form input[name='password']").focus(function(){
            var pwd =  $("form input[name='password']").val();
            if(pwd == '请输入密码'){
                $("form input[name='password']").val('');
                $("form input[name='password']").attr('type','password');
            }
        });
        jQuery("form input[name='username']").focus(function(){
            var pwd =  $("form input[name='username']").val();
            if(pwd == '请输入用户名'){
                $("form input[name='username']").val('');
            }
        });

        jQuery("form input[type='button']").click(function(){
            var $username = $("form input[name='username']").val();
            var $password = $("form input[name='password']").val();
            if($username == '' || $username == '请输入用户名') {
                $("form input[name='username']").val('请输入用户名');
                $("form input[name='username']").css('color','red');
                die;
            }
            if($password == '' || $password == '请输入密码') {
                $("form input[name='password']").attr('type','text');
                $("form input[name='password']").val('请输入密码');
                $("form input[name='password']").css('color','red');
                die;
            }
            $.ajax({
                data: {'username': $username, 'password': $password},
                //dataType: JSON,
                url: '{:url('login/login')}',
                type:'post',
                success:function(data){
                    if(data.status == 0){
                        $('#msg').css('display','block');
                        $('#msg').html(data.message);
                        setTimeout(function () {
                            $('#msg').fadeOut(2000);
                        },1000)
                    }else{
                        $('#submit').css('font-weight','bold');
                        $('#submit').val(data.message);
                        setTimeout(function () {
                            window.location=(data.url)
                        },500)
                    }
                }
            });
        })
    </script>



</body><!--Body Ends--></html>